<template>
  <div class="top-header">
    <div class="logo">
      <svg
        class="heart-icon"
        viewBox="0 0 24 24"
        fill="none"
        stroke="currentColor"
        stroke-width="2"
        stroke-linecap="round"
        stroke-linejoin="round"
      >
        <path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" />
      </svg>
      <span class="page-title">{{ currentPageTitle }}</span>
    </div>
  </div>
</template>

<script setup>
import { ref, watch } from 'vue';
import { useRoute } from 'vue-router';

const route = useRoute();
const currentPageTitle = ref('智慧医疗');

// 监听路由变化，更新页面标题
watch(() => route.path, (newPath) => {
  const pageTitleMap = {
    '/yonghu/home': '首页',
    '/yonghu/online-registration': '在线挂号',
    '/yonghu/my-appointments': '我的预约',
    '/yonghu/hospital-info': '医院信息',
    '/yonghu/my': '我的信息'
  };
  currentPageTitle.value = pageTitleMap[newPath] || '智慧医疗';
});
</script>

<style scoped>
.top-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 99;
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 56px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  background-color: #fff;
}

.logo {
  display: flex;
  align-items: center;
}

.heart-icon {
  width: 24px;
  height: 24px;
  margin-right: 8px;
  color: #165DFF;
}

.page-title {
  font-size: 18px;
  font-weight: bold;
  color: #333;
}
</style>